<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>


    <title>{{$title}}</title>

    <link href="{{URL::asset('/inspinia/css/bootstrap.min.css')}}" rel="stylesheet">
    <script src="{{URL::asset('/inspinia/js/jquery-2.1.1.js')}}"></script>
    <script src="{{URL::asset('/inspinia/js/bootstrap.min.js')}}"></script>

    <link href="{{URL::asset('/inspinia/css/animate.css')}}" rel="stylesheet">
    <link href="{{URL::asset('/inspinia/css/style.css')}}" rel="stylesheet">
    <style>
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
        *:before,
        *:after {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
    </style>

</head>

<body class="gray-bg" style="background: url(/imgs/bg.jpg) no-repeat;background-size: 100% 100%">

<div class="middle-box text-center loginscreen animated fadeInDown" style="    padding-top: 8%;">
    <div style="background-color: rgba(238, 238, 238, 0.3);padding: 20px 20px;border-radius:20px ">

        <div>

            <h1 class="logo-name">DOC</h1>

        </div>
        <h3>欢迎使用文档系统</h3>
        <form class="m-t layui-form" role="form">
            <div class="form-group">
                <input type="text" lay-verify="required" lay-vertype="tips"  name="account" class="form-control account" placeholder="用户名" required=""/>
            </div>
            <div class="form-group">
                <input type="password" lay-verify="required" lay-vertype="tips"  name="password" class="form-control password" placeholder="密码" required=""/>
            </div>
            <div class="form-group">
                <input style="width: 120px;float: left;height: 40px;" type="text" maxlength="5" name="logincode" class="form-control logincode" lay-verify="required" lay-vertype="tips"  placeholder="验证码"/>
                <a onclick="re_captcha();" style="float: right;margin-bottom: 10px;">
                    <img src="{!! URL::route('admin_code',[1]) !!}" alt="验证码" title="刷新图片" width="100" height="40" id="{{ csrf_token()}}" border="0">
                </a>
            </div>
            <button type="button" lay-submit lay-filter="*" class="btn btn-primary block full-width m-b login">Login</button>

            <a class="forgot-pass">
                <small>忘记密码?</small>
            </a>
            <input id="_token" type="hidden" name="_token" value="{{ csrf_token()}}"/>
        </form>
        <p class="m-t">
            <small>Copyright &copy; 2016</small>
        </p>
    </div>
</div>

<script src="{{URL::asset('/Lib/layui/layui.js')}}"></script>

</body>
<script>
    function re_captcha() {
        var $url = "{{ URL::route('admin_code','')}}";
        $url = $url + "/" + Math.random();
        document.getElementById('{{ csrf_token()}}').src = $url;
    }
    $(".m-t").bind("keydown", function (e) {
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13) {
            //回车执行查询
            $(".btn-primary").click();
        }
    });
    $('.forgot-pass').click(function () {
      var  area = ['450px', '160px'];
        //iframe层-父子操作
        layer.open({
            type: 2,
            title: '找回密码',
            area: area,
            fix: false, //不固定
            maxmin: true,
            content: '{{URL::route('admin_login_forgotpassmail')}}'
        });
    });
    function parentRefresh() {
        window.location.reload(true);
    }

    layui.use('form', function(){
        var form = layui.form;
        form.on('submit(*)', function(data){
            var $this = $(data.elem);
            $this.attr('disabled', 'disabled');
            layer.msg('请求中······', {
                icon: 16
                ,shade: 0.01
            },0);
            $.ajax({
                url: '{{URL::route('admin_login_login')}}',// 跳转到 action
                data: data.field,
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    layer.closeAll();
                    if (data['status'] == 1) {
                        location.replace('/Admin/index.html');
                    } else {
                        layer.msg(data['msg'], {icon: 2});
                        re_captcha();
                        $('.logincode').val('');
                    }
                    $this.attr('disabled', false);
                },
                error: function () {
                    layer.closeAll();
                    layer.msg('请求发生错误');
                    $this.attr('disabled', false);
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });


</script>
</html>
